#!/bin/bash

echo "start refresh..."
cd /etc/hyperledger/fabric/
rm -rf msp/*
rm -rf tls/*
cd /etc/hyperledger/fabric/users/msp/
rm -rf ./*

cd /root/
rm -rf $2.$1
rm -f $2.$1.tar.gz
rm -f $2.$1_base64

cp /opt/config/crypto-config/$2.$1_base64 /root/
base64 -d $2.$1_base64 > $2.$1.tar.gz
tar -xzf $2.$1.tar.gz
cp -r $2.$1/peers/$3.$2.$1/msp/* /etc/hyperledger/fabric/msp/
cp -r $2.$1/peers/$3.$2.$1/tls/* /var/hyperledger/fabric/tls/
cp -r $2.$1/users/* /etc/hyperledger/fabric/users/msp/
echo "refresh done..."

